<cfsilent>
	<cfscript>
		//objectAttempt = Event.getValue("objectAttempt");
		attemptQuestions = Event.getValue( "attemptQuestions" );
		attemptID = Event.getValue( "attemptID" );
		oTransfer = Event.getCollection().Transfer;
		index = 1;
	</cfscript>
</cfsilent>
<cfoutput>
<form name="frmQuestions" action="#cgi.SCRIPT_NAME#" method="post">
	<input type="hidden" name="event" value="#Event.getValue("xehAnswer")#">
	<input type="hidden" name="attemptID" value="#attemptID#">

	<cfloop condition="attemptQuestions.hasNext()">
		<cfset oAttemptQuestion = attemptQuestions.Next()>
		<cfset userAnswers = oAttemptQuestion.getUser_Answer_IDs()>
		<cfset questionID = oAttemptQuestion.getQuestion_ID()>
		
		<cfset oQuestion = oTransfer.get( "exam.question", questionID )>
		<cfset oAnswersIterator = oQuestion.getAnswersIterator()>
		
		<!--- get all answers --->
		<cfset stArguments = { question_id = questionID } >
		<cfset qAnswers = oTransfer.listByPropertyMap("exam.answer", stArguments )>

		<cfquery name="qRightAnswers" dbtype="query">
			SELECT * 
			FROM 
				qAnswers
			WHERE 
				question_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#Val(oAttemptQuestion.getQuestion_ID())#">
				AND is_correct = 1;
		</cfquery>
		<cfif qRightAnswers.recordCount gt 1>
			<cfset is_multiple = true>
		<cfelse>
			<cfset is_multiple = false>
		</cfif>

		#index#. #oQuestion.getQuestion()# #oAttemptQuestion.getUser_Answer_IDs()#<br />
		<cfloop condition="#oAnswersIterator.hasNext()#">
			<cfset oAnswer = oAnswersIterator.Next()>
			<cfset selected = "">
			<cfif ListFind( oAttemptQuestion.getUser_Answer_IDs(),oAnswer.getAnswer_ID())>
				<cfset selected = "checked">
			<cfelse>
				<cfset selected = "">
			</cfif>
			<input 
				type	= "<cfif is_multiple>checkbox<cfelse>radio</cfif>" 
				name	= "answer_for_#questionID#" 
				value	= "#oAnswer.getAnswer_ID()#" 
				#selected# />
			#oAnswer.getAnswer()#<br />
		</cfloop>
		<br />
		<cfscript>index = index + 1;</cfscript>
	</cfloop>
	<br />
	<hr />
	If you have finished answering all of the questions, please select "finish" on the selection below: <br />
	<input type="radio" name="action1" value="finish" />Finish<br />
	<input type="radio" name="action1" value="save" CHECKED  />Save<br />
	<input name="submit" type="submit" value="submit"`>
</form>
</cfoutput>